package laf;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.SAXException;

import jade.content.onto.BeanOntologyException;
import jade.core.Profile;
import jade.core.ProfileImpl;
import jade.core.Runtime;
import jade.tools.rma.rma;
import jade.wrapper.AgentController;
import jade.wrapper.ContainerController;
import jade.wrapper.StaleProxyException;
import laf.agents.CognitiveAgent;
import laf.env.ConfigParserHandler;
import laf.env.Enviroment;
import laf.onto.LAFOntology;
import laf.time.Timer;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		SAXParserFactory f = SAXParserFactory.newInstance();
		f.setValidating(true);
		f.setNamespaceAware(false);
		try {
			SAXParser parser = f.newSAXParser();
			parser.parse("D:\\Documents\\Projects\\JADE\\LAF\\config\\test.conf.xml", new ConfigParserHandler());
			
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Enviroment env = Enviroment.getInstance();
		env.start();
		System.out.println("Enviroment Established.");
		
		Runtime jadeRT = Runtime.instance();
		Profile profile = new ProfileImpl();
		ContainerController containerCntr = jadeRT.createMainContainer(profile);
		try {
			AgentController agentCntr = containerCntr.createNewAgent("TestCA", CognitiveAgent.class.getName(), null);
			agentCntr.start();
			agentCntr = containerCntr.createNewAgent("RMA", rma.class.getName(), null);
			agentCntr.start();
		} catch (StaleProxyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
